<script setup>
import { useStudentStore } from '../stores/sudent';
// import { useStudentStore } from '../stores/student2';
let studentStore = useStudentStore();

const changeName = () => {
    // 直接对state操作即可，state对象是reactive的，不用.value就可以直接操作
    // studentStore.name = '小华';
    // studentStore.gender = 0;
    studentStore.$patch({
        name: '小华',
        gender: 0
    })
}

</script>

<template>
    <div>
        {{ studentStore.name }}-{{ studentStore.age }}-{{ studentStore.genderStr }}
        <button @click="studentStore.changeName('李四')">改变名称</button>
        <button @click="changeName">组件改信息</button>
        <button @click="studentStore.$reset();">状态重置</button>
    </div>
</template>